package cn.wolfcode.controller;

import cn.wolfcode.domain.BookType;
import cn.wolfcode.service.BookTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
@RequestMapping("/booktype")
public class BookTypeController {

    @Autowired
    private BookTypeService bookTypeService;

    @RequestMapping("/list")
    public String list(Model model) {
        List<BookType> list = bookTypeService.list();
        model.addAttribute("list", list);
        return "booktype/list";
    }

    @RequestMapping("/delete")
    public String delete(Integer id) {
        bookTypeService.removeById(id);
        return "redirect:/booktype/list";
    }

}
